package com.codemate.interview.rabbit;

import com.codemate.interview.constant.RabbitConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * rabbit延时队列监听器
 *
 * @author hice
 */
@Slf4j
@Component
public class RabbitDelayListener {

    @RabbitHandler
    @RabbitListener(queues = RabbitConstant.DELAY_QUEUE_KEY)
    public void onMessageForDelayQueue(Message message) {
        log.info("使用延时队列，收到消息：{}", new String(message.getBody()));
    }

    @RabbitHandler
    @RabbitListener(queues = RabbitConstant.DELAY_VARIABLE_QUEUE_KEY)
    public void onMessageForVariableDelayQueue(Message message) {
        log.info("使用可变延时队列，收到消息：{}", new String(message.getBody()));
    }

}
